#pragma once

#include <vector>
#include <algorithm>
#include <boost/regex.hpp>
#include <boost/bind.hpp>
 
using namespace std;
using namespace boost;

class ProcessNameFilter {
	typedef vector<regex> ListRegex;
	ListRegex _regexes;

public:
	inline void addRegex(const string &s) {
		_regexes.push_back(regex(s, boost::regex::perl | boost::regex::icase));
	}

	inline void addRegexList(const vector<string> &vs) {
		for_each(vs.begin(), vs.end(),
			boost::bind(&ProcessNameFilter::addRegex, boost::ref(*this), _1));
	}

	inline bool filterProcess(const string &name) {
		if (_regexes.empty()) return true;
		for (ListRegex::iterator it = _regexes.begin(); it != _regexes.end(); ++it)
			if (regex_match(name, *it))
				return true;
		return false;
	}
};